var appPath = getAppPath();
function exportExcel(gridId,fields,moduleName){
	var content = '';
	var titleArray = new Array();
	for(var i = 0; i < fields.length; i++){
		var field = fields[i];
		var title = $("#"+gridId).datagrid("getColumnOption",field).title;
		if(title == null) title = " ";
		titleArray.unshift(title);
	}
	content = content + titleArray.toString()+';';
	var rows = $("#"+gridId).datagrid("getRows");
	
	for(var i = 0; i < rows.length; i++){
		var rowArray = new Array();
		for(var j = 0; j < fields.length; j++){
			var value = eval('rows['+i+'].'+fields[j]);
			if(value == null) value = ' ';
			rowArray.unshift(value);
		}
		content = content + rowArray.toString()+';';
	}
	document.getElementById("contentExcelDataId").value=content;
	document.getElementById("contentModuleId").value = moduleName;
	var form = document.getElementById("exportFormId");
	if (window.ActiveXObject){
		form.action = appPath+'/system/attach_export.do?IeFlag=1';
	}else{
		form.action = appPath+'/system/attach_export.do';
	} 
	form.submit();
}
